﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

// std headers
#include <memory>
#include <vector>

// qt headers
#include <QFrame>
#include <QItemSelection>

// custom headers
#include "CustomDrawer.h"


class QPushButton;

namespace gmepgcs
{
    class EdittingParametersTableView;
    struct IParameter;
}

namespace gmepgcs
{
    class ParametersEditingCard :public CustomDrawer
    {
        Q_OBJECT

    public:
        explicit ParametersEditingCard(QString &title, QString &subTitle, QWidget *parent = nullptr);
        virtual ~ParametersEditingCard();

    public:
        void SetParameters(std::vector<std::shared_ptr<IParameter>> paramters);
        //void UpdateParameterName(const std::wstring &parameterOldName, const std::wstring &parameterNewName);
        void UpdateParameterValue(const std::wstring &parameterName, const std::wstring &parameterOldValue, const std::wstring &parameterNewValue);
        //void UpdateParameterUnit(const std::wstring &parameterName, const std::wstring &parameterOldUnit, const std::wstring &parameterNewUnit);
        void UpdateParameterIsInstance(const std::wstring &parameterName, const bool &parameterOldIsInstance, const bool &parameterNewIsInstance);
        //void ClearSelection();

    signals:
        void AddingParamtersRequired();
        void RemoveParameterRequired(const std::wstring &parameterName);
        //void ModifyNameOfParameterRequired(const std::wstring &parameterOldName, const std::wstring &parameterNewName);
        void ModifyValueOfParameterRequired(const std::wstring &parameterName, const std::wstring &parameterOldValue, const std::wstring &parameterNewValue);
        //void ModifyUnitOfParameterRequired(const std::wstring &parameterName, const std::wstring &parameterOldUnit, const std::wstring &parameterNewUnit);
        //void ModifyIsInstanceOfParameterRequired(const std::wstring &parameterName, const bool &parameterOldIsInstance, const bool &parameterNewIsInstance);
        void SelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
        void ParametersChanged();

    private:
        void InitUI();

    private:
        QPushButton *m_pBtnDelete;
        QPushButton *m_pBtnAdd;
        EdittingParametersTableView *m_pTable;

    private:
        QString m_title;
        QString m_subTitle;
    };
}